package gameobj;

import render.Model;
import window.MainWindow;

/**
 * @名称 角色类
 * @author YOU
 * @二作 Passerby
 * @说明
 * 所有能动的物体都是角色类的子类
 */

public abstract class Character extends GameObject{
	
	private int speed;
//	true代表上，false代表下，主要是控制子弹
	private boolean direction;
	
	@Override
	public void ObjRun() {
		move();
	}

	
	public int getSpeed() {
		return speed;
	}


	public void setSpeed(int speed) {
		this.speed = speed;
	}
	
	public void setDirection(boolean updown) {
		this.direction = updown;
	}


	public Character (){}
	public Character (int x,int y,int w,int h,Model model) {
		super();
		this.setX(x);
		this.setY(y);
		this.setW(w);
		this.setH(h);
		this.setModel(model);
	}
	
	protected void move()
	{
		if (direction) {
//			如果是向上飞
			this.setY(this.getY() - this.speed);
		} else {
			this.setY(this.getY() + this.speed);
		}
		
		if (getY() > MainWindow.WINDOWY || getY() < 0) {
			this.setAlive(false);
		}
	}
	
}
